﻿@using TSites.Core.Domain.MenuMgmt;
@using TSites.Administrator.Extensions;
@model TSites.Administrator.Models.MenuMgmtModel
@{
    ViewBag.Title = "Index";
}

@{
    Layout = null;
}
@helper TreeMenu(IEnumerable<Menu> listMenu)
{
    foreach(Menu menu in listMenu)
    {
        <li class="open">
            @if(menu.IsLeaf)
            {
                <a href="@menu.MenuUrl">@menu.MenuName</a>
            }
            else
            {
                <a href="@menu.MenuUrl">@menu.MenuName</a>
                <ul>
                    @TreeMenu(menu.SubMenus)
                </ul>                
            }
        </li>
    }
}
<!DOCTYPE html>

<html>
<head>
    <title>Menu Management</title>    
    <link href="@Url.Stylesheet("tree_component.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Script("TSAdmin/lib/css.js")" type="text/javascript"></script>
    <script src="@Url.Script("jquery-1.5.1.js")" type="text/javascript"></script>
    <script src="@Url.Script("TSAdmin/tree_component.js")" type="text/javascript"></script>
    <script type="text/javascript">
        conf = {
            // Rest omitted
            ui: {
//                theme_path: "../../Content/themes/tree/menu/",
                theme_name: "classic"
            }
        };

        $(document).ready(function () {
            $("#divTreeMenu").tree($.extend({}, conf))
        });


    </script>
</head>
<body>
<div style="width:100%; height:100%">
    <div id="divTreeMenu" style="float:left;width:40%; left:10px">
        <ul>
           @TreeMenu(Model.ListMenu)
       </ul>
	    @*<ul>
		    <li id="phtml_1" class="open"><a href="#">Root node 1</a>
			    <ul>
				    <li id="phtml_2" class="open"><a href="#" style="background-image:url('../media/images/ok.png');">Custom icon</a>
                        <ul>
                            <li id="phtml_3e"><a href="#">Extend node</a></li>
                        </ul>
                    </li>
				    <li id="phtml_3"><a href="#">Child node 2</a></li>
				    <li id="phtml_4"><a href="#">Some other child node 111</a></li>
			    </ul>
		    </li>
		    <li id="phtml_5"><a href="#">Root node 2</a></li>
	    </ul> *@
    </div>
    <div id="divMenuDtl" style="float:left;width:60%">
        @using (Html.BeginForm("Update", "MenuMgmt", FormMethod.Post))
        {
             <div>
              <fieldset>
                <table style="border:1px thin red">
                    <tbody>
                        <tr >
                            <th >Menu Item Information</th>
                        </tr>
                    </tbody>
                    <tr>
                        <td>Menu Id</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.ID)</td>
                    </tr>
                    <tr>
                        <td>Menu Name</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.MenuName)</td>
                    </tr>
                    <tr>
                        <td>Menu URL</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.MenuUrl)</td>
                    </tr>
                    <tr>
                        <td>Module</td>
                        <td>@Html.TextBox("News")</td>
                        <td>Map For</td>
                        <td>@Html.TextBox("Computer")</td>
                    </tr>
                    <tr>
                        <td>Menu Description</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.MenuDescription)</td>
                    </tr>
                     <tr>
                        <td>Message Code</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.MessageCode)</td>
                    </tr>
                     <tr>
                        <td>Order Number</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.OrderNumber)</td>
                    </tr>
                     <tr>
                        <td>Parent Menu</td>
                        <td>@Html.TextBoxFor(m => m.CurMenu.ParentMenuId)</td>
                    </tr>
                </table>
                <input type="submit" value="Save" />
                 </fieldset>
            </div>
        }
    </div>
</div>
</body>
</html>


